home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Interactive 7
/
PC World Interactive 7.iso
/
program
/
ctutor.exe
/
ANSWERS
/
CH10_3.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-05-15
|
747b
|
32 lines
/* Chapter 10 - Program 7 */
#include "stdio.h"
void main()
{
FILE *fp1;
char oneword[100], filename[25];
char *c;
printf("Enter filename -> ");
scanf("%s", filename); /* read the desired filename */
fp1 = fopen(filename, "r");
if (fp1 == NULL)
printf("File doesn't exist\n");
else {
do {
c = fgets(oneword, 100, fp1); /* get a line from the file */
if (c != NULL)
printf("%s", oneword); /* display it on the monitor */
} while (c != NULL); /* repeat until NULL */
}
fclose(fp1);
}
/* Result of execution
(The output depends on weather you type in a good filename.)
*/